<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% String path = request.getContextPath(); %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>
<script src="<%=path%>/js/jquery-3.2.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$('#addBook').click(
		function() {
			window.location.href="BookAddServlet?backurl="+window.location.href; 
		}	
	);
});
</script>
</head>
<body>
<div style="float: right;">
	<a href="UserRegisterServlet">注册</a><span> |</span>
	<a href="UserLoginServlet">登录</a>
</div>

${welMsg }${user.username }<br>
<table border="1" cellspacing="0" style="margin: auto;">
	<thead style="font-size: 30px">
		<tr>
			<th colspan="6">图书列表</th>
		</tr>
	</thead>
	<tr style="font-size: 20px">
		<td>书名</td>
		<td>作者</td>
		<td>描述</td>
		<td>价格</td>
		<td>分类</td>
		<td>操作</td>
	</tr>
<c:forEach var="b" items="${booklist}">
	<tr>
		<td>${b.name }</td>
		<td>${b.author }</td>
		<td>${b.describe }</td>
		<td>${b.price }</td>
		<td>${b.category.name }</td>
		<td><a href="BookDelServlet?book_id=${b.id }">删除</a></td>
	</tr>
</c:forEach>
	<tr>
		<td colspan="4"></td>
		<td colspan="2"><button id="addBook">新增图书</button></td>
	</tr>
</table>
</body>
</html>